//
//  CollectionVC.m
//  K-Music
//
//  Created by 林杰良 on 16/1/4.
//  Copyright © 2016年 CHUN. All rights reserved.
//

#import "CollectionVC.h"

@interface CollectionVC ()
@property(nonatomic,strong)UICollectionView*ShowCollectionView;

@end

@implementation CollectionVC
-(void)backTheFirstPage{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createrleftBTN{
    UIButton*leftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame=CGRectMake(0, 20, 10, 15);
    [leftBtn setBackgroundImage:[UIImage imageNamed:@"top_menu_left_back_ico_1.png"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(backTheFirstPage) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem*leftItem=[[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem=leftItem;
    
    UILabel *MenuText = [[UILabel alloc] initWithFrame:CGRectMake(130, 0, 120, 50)];
    
    MenuText.backgroundColor = [UIColor clearColor];
    
    MenuText.textColor=[UIColor blackColor];
    
    MenuText.textAlignment=NSTextAlignmentCenter;
    
    [MenuText setFont:[UIFont systemFontOfSize:17.0f]];
    
    [MenuText setText:@"历史房间"];
    
    self.navigationItem.titleView=MenuText;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createrleftBTN];
    // Do any additional setup after loading the view.
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    _ShowCollectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, WIDTH  , HEIGHT)collectionViewLayout:flowLayout];
    _ShowCollectionView.delegate=self;
    _ShowCollectionView.dataSource=self;
    _ShowCollectionView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_ShowCollectionView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 20;
}

-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    [_ShowCollectionView registerClass:[CollectionCell class] forCellWithReuseIdentifier:@"CollectionCell"];
    
    CollectionCell*cell=(CollectionCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell" forIndexPath:indexPath];
    
    
    return cell;
}




-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    

    
    
    
}


//定义每一个cell大小
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(WIDTH/2-2, HEIGHT/4);
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 1;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 1;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
